﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MxitAPI;

namespace MxitGUI {
    public partial class EditContactWindow : Form {

        private Contact contact;

        public EditContactWindow( Contact contact ) {
            InitializeComponent();
            this.contact = contact;
            Init();
        }

        private void Init() {
            txtGroup.Text = contact.Group;
            txtNickName.Text = contact.NickName;
        }

        private void btnOK_Click( object sender, EventArgs e ) {
            new UpdateContactInfoHandler( txtGroup.Text, contact.ContactAddress, txtNickName.Text ).Execute();
            contact.NickName = txtNickName.Text;
            contact.Group = txtGroup.Text;
            contact.DoContactChanged();
            new GetContactsHandler().Execute();
            DialogResult = DialogResult.OK;
            Close();
        }

        private void btnCancel_Click( object sender, EventArgs e ) {
            DialogResult = DialogResult.Cancel;
            Close();
        }
    }
}
